from socket import *
from time import ctime

HOST = ''# IP地址
PORT = 3555# 端口号
BUFSIZ = 1024# 缓存长度
ADDR = (HOST, PORT)# 地址

udpServerSocket = socket(AF_INET, SOCK_DGRAM)# 创建一个套接字
udpServerSocket.bind(ADDR)# 将端口号与套接字进行绑定

while True:
    msg, addr = udpServerSocket.recvfrom(BUFSIZ)# 接受数据
    print(msg.decode('utf-8'))# 将数据解码
    reply = 'Hello, this is udpserver!'
    udpServerSocket.sendto(reply.encode('utf-8'), addr)# 回复信息